//连接数据库
var mysql=require("mysql");
var pool = mysql.createPool({
	host: '101.200.89.202',
	user: 'root',
	password: 'diabetes',
	database:'diabetes'
});

var query=function(sql,data, callback){
	pool.getConnection(function(err,conn){
		if(err){
			callback(err,null,null);
		}else{
			conn.query(sql,data,function(qerr,vals,fields){
				//释放连接
				conn.release();
				//事件驱动回调
				callback(qerr,vals,fields);
			});
		}
	});
};

module.exports = query;

